package com.gitee.huxing.clone;

/**
 * @Description:
 * @ProjectName: AlgorithmicPactice
 * @Package: com.gitee.huxing.clone
 * @ClassName: Student
 * @Author: huxing
 * @DateTime: 2022-04-11 4:58 PM
 */
public class Student implements Cloneable{

    private String name;
    private int age;
    private Teacher teacher;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        // 深拷贝复制
        Student student = (Student) super.clone();
        student.setTeacher((Teacher) student.getTeacher().clone());
        return student;
    }
}
